package cn.tedu.egmvc1.controller;


import cn.tedu.egmvc1.Pojo.VO.EmpOV;
import cn.tedu.egmvc1.Pojo.entity.Emp;
import cn.tedu.egmvc1.mapper.EmpMapper;
import cn.tedu.egmvc1.Pojo.dto.empDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp/")
public class empController {


    @Autowired
    EmpMapper empMapper;
    @RequestMapping("insert")
    public String insertEmp(empDTO empDTO) {

        empMapper.insertEmp(empDTO);
        return "添加成功";
    }

    @RequestMapping("select")
    public List<EmpOV> findAllemp() {
        List<EmpOV> empOVs = empMapper.findAllemp();
        return empOVs;
    }

    @RequestMapping("updata")
    public String updateEmp(Emp emp) {
        empMapper.updateEmp(emp);
        return "修改成功";
    }

    @RequestMapping("delete")
    public String delete(Long id) {
        empMapper.delete(id);
        return "删除成功";
    }



}
